﻿Public Class TMyViews
    Inherits TCustomMyObjects

    Friend Sub New(ByVal AOwner As TMyDatabase)
        MyBase.New(AOwner)
    End Sub

    Public Overrides Sub Refresh()
        Dim item As TMyView
        _List.Clear()
        MyQuery.Clear()
        MyQuery.SQL.AppendLine("SELECT")
        MyQuery.SQL.AppendLine(" TABLE_CATALOG")
        MyQuery.SQL.AppendLine(",TABLE_SCHEMA")
        MyQuery.SQL.AppendLine(",TABLE_NAME")
        MyQuery.SQL.AppendLine(",VIEW_DEFINITION")
        MyQuery.SQL.AppendLine(",CHECK_OPTION")
        MyQuery.SQL.AppendLine(",IS_UPDATABLE")
        MyQuery.SQL.AppendLine(",DEFINER")
        MyQuery.SQL.AppendLine(",SECURITY_TYPE")
        MyQuery.SQL.AppendLine(",CHARACTER_SET_CLIENT")
        MyQuery.SQL.AppendLine(",COLLATION_CONNECTION")
        MyQuery.SQL.AppendLine("FROM")
        MyQuery.SQL.AppendLine(" information_schema.views")
        MyQuery.SQL.AppendLine("where")
        MyQuery.SQL.AppendLine("table_schema=?table_schema")
        MyQuery.SQL.AppendLine("order by")
        MyQuery.SQL.AppendLine(" table_name")
        MyQuery.DeclareAndSet("table_schema", Me.DatabaseName)
        MyQuery.Execute()
        While Not MyQuery.Eof
            item = New TMyView(Me, MyQuery.FieldAsString("table_name"))
            item._TableCatalog = MyQuery.FieldAsString("table_catalog")
            item._TableSchema = MyQuery.FieldAsString("table_schema")
            item._TableName = MyQuery.FieldAsString("table_name")
            item._ViewDefinition = MyQuery.FieldAsString("view_definition")
            item._CheckOption = MyQuery.FieldAsString("check_option")
            item._IsUpdatable = MyQuery.FieldAsString("is_updatable")
            item._Definer = MyQuery.FieldAsString("definer")
            item._SecurityType = MyQuery.FieldAsString("security_type")
            item._CharacterSetClient = MyQuery.FieldAsString("character_set_client")
            item._CollationConnection = MyQuery.FieldAsString("collation_connection")
            _List.Add(item)
            MyQuery.MoveNext()
        End While
        MyQuery.Close()

    End Sub
End Class
